
package system.base;

import java.util.StringTokenizer;

import com.hitrust.gs.lib.GSAutoAuditongDateConfigurator;
import com.hitrust.gs.lib.GSBaseConstants;

import framework.core.Condition;
import framework.core.Conditions;
import framework.core.DBConnection;
import framework.core.ObjectList;
import framework.core.SearchEvent;
import framework.core.Value;

/*
	Author    :chengbiao.he
	CreateTime:2008-01-30 14:21:49
*/
public class ProductSearchTempEvent extends SearchEvent
{
    
    
    private String m_key_word = "";
	private String m_id = "" ; // all

	private String m_concentricity_code = "" ; // all

	private String m_apep_code = "" ; // all

	private String m_name = "" ; // all

	private String m_category_code = "" ; // all

	private String m_product_brand = "" ; // all

	private String m_model = "" ; // all

	private String m_spec = "" ; // all

	private double m_unit_price = Value.NULL_DOUBLE ; // all

	private String m_product_unit = "" ; // all

	private String m_quality_assure_period = "" ; // all

	private String m_manufaturer = "" ; // all

	private String m_area = "" ; // all

	private String m_provider_code = "" ; // all

	private String m_adapt_machine_type = "" ; // all

	private String m_pic = "" ; // all

	private String m_recent_adjustprice_date = "" ; // all

	private double m_recent_adjusted_price = Value.NULL_DOUBLE ; // all

	private String m_recorder_id = "" ; // all

	private String m_record_date = "" ; // all

	private String m_is_tradeflat_product = "" ; // all

	private String m_appender_property = "" ; // all

	private String m_remark = "" ; // all

	private String m_drawing_piece_code = "" ; // all

	private String m_balance_mode = "" ; // all

	private String m_is_normal = "" ; // all

	private String m_warehouse_code = "" ; // all

	private String m_warehouse_name = "" ; // all

	private String m_is_buy = "" ; // all

	private String m_status = "" ; // all
	
	private String m_auditing_status = "" ; // all
	
	private boolean is_auditing = false;
	   

	private String m_create_user_id = "" ; // all

	private String m_create_user = "" ; // all

	private String m_create_time = "" ; // all

	private String m_last_update_user_id = "" ; // all

	private String m_last_update_user = "" ; // all

	private String m_last_update_time = "" ; // all
	//private String i_mhcx="";

	private String m_create_time_start = "";
	
	private String m_create_time_end = "";
	
	//2009-05-22
	private String m_provider_status = "";
	//是否查询出入库产品里没有设置产品分类的产品
	private String m_is_warehouse_category_product="";
	
	private String m_searh_warehouse_code = "";
	
	private String m_product_type_provider_code = "" ; // all
	
	private String m_is_pic = "" ; // all
	
/**
     * @return the i_mhcx
     */
   
	/*public String getI_mhcx() {
        return this.i_mhcx;
    }
    */



    /**
     * @return the m_searh_warehouse_code
     */
    public String getSearhWarehouseCode() {
        return this.m_searh_warehouse_code;
    }



    /**
     * @param aM_searh_warehouse_code the m_searh_warehouse_code to set
     */
    public void setSearhWarehouseCode(String aM_searh_warehouse_code) {
        this.m_searh_warehouse_code = aM_searh_warehouse_code;
    }



    /**
     * @param aI_mhcx the i_mhcx to set
     */
   /* public void setI_mhcx(String aI_mhcx) {
        this.i_mhcx = aI_mhcx;
    }
*/


public ProductSearchTempEvent() 
{
	super();
	
	setOrderField(Product.ID);
		
}



	public String getId()
	{
		return m_id ;
	}
	public void setId(String v)
	{
		m_id = v;
	}

	public String getConcentricityCode()
	{
		return m_concentricity_code ;
	}
	public void setConcentricityCode(String v)
	{
		m_concentricity_code = v;
	}

	public String getApepCode()
	{
		return m_apep_code ;
	}
	public void setApepCode(String v)
	{
		m_apep_code = v;
	}

	public String getName()
	{
		return m_name ;
	}
	public void setName(String v)
	{
		m_name = v;
	}

	public String getCategoryCode()
	{
		return m_category_code ;
	}
	public void setCategoryCode(String v)
	{
		m_category_code = v;
	}

	public String getProductBrand()
	{
		return m_product_brand ;
	}
	public void setProductBrand(String v)
	{
		m_product_brand = v;
	}

	public String getModel()
	{
		return m_model ;
	}
	public void setModel(String v)
	{
		m_model = v;
	}

	public String getSpec()
	{
		return m_spec ;
	}
	public void setSpec(String v)
	{
		m_spec = v;
	}

	public double getUnitPrice()
	{
		return m_unit_price ;
	}
	public void setUnitPrice(double v)
	{
		m_unit_price = v;
	}

	public String getProductUnit()
	{
		return m_product_unit ;
	}
	public void setProductUnit(String v)
	{
		m_product_unit = v;
	}

	public String getQualityAssurePeriod()
	{
		return m_quality_assure_period ;
	}
	public void setQualityAssurePeriod(String v)
	{
		m_quality_assure_period = v;
	}

	public String getManufaturer()
	{
		return m_manufaturer ;
	}
	public void setManufaturer(String v)
	{
		m_manufaturer = v;
	}

	public String getArea()
	{
		return m_area ;
	}
	public void setArea(String v)
	{
		m_area = v;
	}

	public String getProviderCode()
	{
		return m_provider_code ;
	}
	public void setProviderCode(String v)
	{
		m_provider_code = v;
	}

	public String getAdaptMachineType()
	{
		return m_adapt_machine_type ;
	}
	public void setAdaptMachineType(String v)
	{
		m_adapt_machine_type = v;
	}

	public String getPic()
	{
		return m_pic ;
	}
	public void setPic(String v)
	{
		m_pic = v;
	}

	public String getRecentAdjustpriceDate()
	{
		return m_recent_adjustprice_date ;
	}
	public void setRecentAdjustpriceDate(String v)
	{
		m_recent_adjustprice_date = v;
	}

	public double getRecentAdjustedPrice()
	{
		return m_recent_adjusted_price ;
	}
	public void setRecentAdjustedPrice(double v)
	{
		m_recent_adjusted_price = v;
	}

	public String getRecorderId()
	{
		return m_recorder_id ;
	}
	public void setRecorderId(String v)
	{
		m_recorder_id = v;
	}

	public String getRecordDate()
	{
		return m_record_date ;
	}
	public void setRecordDate(String v)
	{
		m_record_date = v;
	}

	public String getIsTradeflatProduct()
	{
		return m_is_tradeflat_product ;
	}
	public void setIsTradeflatProduct(String v)
	{
		m_is_tradeflat_product = v;
	}

	public String getAppenderProperty()
	{
		return m_appender_property ;
	}
	public void setAppenderProperty(String v)
	{
		m_appender_property = v;
	}

	public String getRemark()
	{
		return m_remark ;
	}
	public void setRemark(String v)
	{
		m_remark = v;
	}

	public String getDrawingPieceCode()
	{
		return m_drawing_piece_code ;
	}
	public void setDrawingPieceCode(String v)
	{
		m_drawing_piece_code = v;
	}

	public String getBalanceMode()
	{
		return m_balance_mode ;
	}
	public void setBalanceMode(String v)
	{
		m_balance_mode = v;
	}

	public String getIsNormal()
	{
		return m_is_normal ;
	}
	public void setIsNormal(String v)
	{
		m_is_normal = v;
	}

	public String getWarehouseCode()
	{
		return m_warehouse_code ;
	}
	public void setWarehouseCode(String v)
	{
		m_warehouse_code = v;
	}

	public String getWarehouseName()
	{
		return m_warehouse_name ;
	}
	public void setWarehouseName(String v)
	{
		m_warehouse_name = v;
	}

	public String getIsBuy()
	{
		return m_is_buy ;
	}
	public void setIsBuy(String v)
	{
		m_is_buy = v;
	}
	public String getIsPic() {
		return m_is_pic;
	}
	public void setIsPic(String v) {
		this.m_is_pic = v;
	}
	public String getStatus()
	{
		return m_status ;
	}
	public void setStatus(String v)
	{
		m_status = v;
	}

	   public String getAuditingStatus()
	    {
	        return m_auditing_status ;
	    }
	    public void setAuditingStatus(String v)
	    {
	        m_auditing_status = v;
	    }
	
	
	public String getCreateUserId()
	{
		return m_create_user_id ;
	}
	public void setCreateUserId(String v)
	{
		m_create_user_id = v;
	}

	public String getCreateUser()
	{
		return m_create_user ;
	}
	public void setCreateUser(String v)
	{
		m_create_user = v;
	}

	public String getCreateTime()
	{
		return m_create_time ;
	}
	public void setCreateTime(String v)
	{
		m_create_time = v;
	}

	public String getLastUpdateUserId()
	{
		return m_last_update_user_id ;
	}
	public void setLastUpdateUserId(String v)
	{
		m_last_update_user_id = v;
	}

	public String getLastUpdateUser()
	{
		return m_last_update_user ;
	}
	public void setLastUpdateUser(String v)
	{
		m_last_update_user = v;
	}

	public String getLastUpdateTime()
	{
		return m_last_update_time ;
	}
	public void setLastUpdateTime(String v)
	{
		m_last_update_time = v;
	}
	
	public String getCreateTimeStart()
	{
	    return m_create_time_start;
	}
	public void setCreateTimeStart(String v)
	{
	    m_create_time_start = v;
	}
	
	public String getCreateTimeEnd()
    {
        return m_create_time_end;
    }
    public void setCreateTimeEnd(String v)
    {
        m_create_time_end = v;
    }
		
    public void setKeyWord(String v)
    {
        m_key_word = v;
    }
    
    public String getProviderStatus()
    {
        return m_provider_status;
    }
    public void setProviderStatus(String v)
    {
        m_provider_status = v;
    }


	public String viewId() throws Exception
	{
		return Value.view(getId());
	}

	public String viewConcentricityCode() throws Exception
	{
		return Value.view(getConcentricityCode());
	}

	public String viewApepCode() throws Exception
	{
		return Value.view(getApepCode());
	}
/* public String viewI_mhcx()throws Exception{
     return Value.view(getI_mhcx());
 }
 */
	public String viewName() throws Exception
	{
		return Value.view(getName());
	}

	public String viewCategoryCode() throws Exception
	{
		return Value.view(getCategoryCode());
	}

	public String viewProductBrand() throws Exception
	{
		return Value.view(getProductBrand());
	}

	public String viewModel() throws Exception
	{
		return Value.view(getModel());
	}

	public String viewSpec() throws Exception
	{
		return Value.view(getSpec());
	}

	public String viewUnitPrice() throws Exception
	{
		return Value.view(getUnitPrice());
	}

	public String viewProductUnit() throws Exception
	{
		return Value.view(getProductUnit());
	}

	public String viewQualityAssurePeriod() throws Exception
	{
		return Value.view(getQualityAssurePeriod());
	}

	public String viewManufaturer() throws Exception
	{
		return Value.view(getManufaturer());
	}

	public String viewArea() throws Exception
	{
		return Value.view(getArea());
	}

	public String viewProviderCode() throws Exception
	{
		return Value.view(getProviderCode());
	}

	public String viewAdaptMachineType() throws Exception
	{
		return Value.view(getAdaptMachineType());
	}

	public String viewPic() throws Exception
	{
		return Value.view(getPic());
	}

	public String viewRecentAdjustpriceDate() throws Exception
	{
		return Value.view(getRecentAdjustpriceDate());
	}

	public String viewRecentAdjustedPrice() throws Exception
	{
		return Value.view(getRecentAdjustedPrice());
	}

	public String viewRecorderId() throws Exception
	{
		return Value.view(getRecorderId());
	}

	public String viewRecordDate() throws Exception
	{
		return Value.view(getRecordDate());
	}

	public String viewIsTradeflatProduct() throws Exception
	{
		return Value.view(getIsTradeflatProduct());
	}

	public String viewAppenderProperty() throws Exception
	{
		return Value.view(getAppenderProperty());
	}

	public String viewRemark() throws Exception
	{
		return Value.view(getRemark());
	}

	public String viewDrawingPieceCode() throws Exception
	{
		return Value.view(getDrawingPieceCode());
	}

	public String viewBalanceMode() throws Exception
	{
		return Value.view(getBalanceMode());
	}

	public String viewIsNormal() throws Exception
	{
		return Value.view(getIsNormal());
	}

	public String viewWarehouseCode() throws Exception
	{
		return Value.view(getWarehouseCode());
	}

	public String viewWarehouseName() throws Exception
	{
		return Value.view(getWarehouseName());
	}

	public String viewIsBuy() throws Exception
	{
		return Value.view(getIsBuy());
	}

	public String viewStatus() throws Exception
	{
		return Value.view(getStatus());
	}
	
	   public String viewAuditingStatus() throws Exception
	    {
	        return Value.view(getAuditingStatus());
	    }

	public String viewCreateUserId() throws Exception
	{
		return Value.view(getCreateUserId());
	}

	public String viewCreateUser() throws Exception
	{
		return Value.view(getCreateUser());
	}

	public String viewCreateTime() throws Exception
	{
		return Value.view(getCreateTime());
	}

	public String getKeyWord()
    {
        return m_key_word;
    }
    public String viewKeyWord() throws Exception
    {
        return Value.view(getKeyWord());
    }
	public String viewLastUpdateUserId() throws Exception
	{
		return Value.view(getLastUpdateUserId());
	}

	public String viewLastUpdateUser() throws Exception
	{
		return Value.view(getLastUpdateUser());
	}

	public String viewLastUpdateTime() throws Exception
	{
		return Value.view(getLastUpdateTime());
	}
	
	public String viewCreateTimeStart() throws Exception
    {
        return Value.view(getCreateTimeStart());
    }
	
	public String viewCreateTimeEnd() throws Exception
    {
        return Value.view(getCreateTimeEnd());
    }
	
	public String viewProviderStatus()
    {
        return Value.view(getProviderStatus());
    }


	public Conditions toConditions() throws Exception
	{
		Conditions c = super.toConditions();

	c.add(getCondition(Product.ID,getId()));

	c.add(getCondition(Product.CONCENTRICITY_CODE,getConcentricityCode()));

	c.add(getCondition(Product.APEP_CODE,getApepCode()));

	c.add(getCondition(Product.NAME,getName()));
	c.add(getCondition(Product.STATUS, getStatus()));
	c.add(getCondition(Product.IS_BUY, getIsBuy()));
	//c.add(getCondition(Product.CATEGORY_CODE,getCategoryCode()));
	//分类编码查询
	String categorycode3 = getGrandfatherCategoryCode();
	String categorycode2 = getUpperCategoryCode();
	String categorycode1 = getCategoryCode();
	if (!getStatus().equals(""))
	{
	    c.add(getCondition(Product.STATUS,getStatus()));
	}
	
	if (!getIsBuy().equals(""))
	{
	    c.add(getCondition(Product.IS_BUY,getIsBuy()));
	}
	if (categorycode3== null || categorycode3.equalsIgnoreCase("null") || categorycode3.equalsIgnoreCase("")) 
	{
	    categorycode3 = "";
	    setGrandfatherCategoryCode(categorycode3);
	}    
	if (categorycode2== null || categorycode2.equalsIgnoreCase("null") || categorycode2.equalsIgnoreCase(""))
    {
	    categorycode2 = "";
	    setUpperCategoryCode(categorycode2);
    }
    if (categorycode1== null || categorycode1.equalsIgnoreCase("null") || categorycode1.equalsIgnoreCase("")) 
    {
        categorycode1 = "";
        setCategoryCode(categorycode1);
    }
	if (!categorycode1.equals(""))
	{
	    c.add(getCondition(Product.CATEGORY_CODE,categorycode1));
	}
	else if (!categorycode2.equals(""))
	{
	    c.add(Product.CATEGORY_CODE + " in (select code from t_product_category where CATEGORY_ID2= ? or code=? )",Conditions.CUSTOM,new String[]{categorycode2,categorycode2});
	}
	else if (!categorycode3.equals(""))
	{
   
	    c.add(Product.CATEGORY_CODE + " in (select code from t_product_category where CATEGORY_ID1= ? or code=? )",Conditions.CUSTOM,new String[]{categorycode3,categorycode3}); 
	}
	String isPic=getIsPic();
	if("1".equals(isPic)){
		c.add(" CONCENTRICITY_CODE in (select CONCENTRICITY_CODE from t_product_picture) ");
	}else if("0".equals(isPic)){
		c.add(" CONCENTRICITY_CODE not in (select CONCENTRICITY_CODE from t_product_picture) ");
	}
	
	String upperType = getUpperType();  //区域
	String productType = getProductType();//招标分类
	String providerCode = getProductTypeProviderCode();//供应商
	
	String isCountProductType=getIsCountProductType();//是否关联T_PRODUCT_TYPE表查询所有status=1的记录
	if("1".equals(isCountProductType)){
		c.add(" id in (select product_id from t_product_type where status='1') ");
	}
	
	if(!upperType.equals("")){
		c.add(" id in (select product_id from t_product_type where status='1' and  product_type="+upperType+") ");
	}
	
	if(!productType.equals("")){
		c.add(" id in (select product_id from t_product_type where status='1' and is_bid="+productType+") ");			
	}
	
	if(!providerCode.equals("")){
		c.add(" id in (select product_id from t_product_type where status='1' and provider_code="+providerCode+") ");			
	}
	
	c.add(getCondition(Product.PRODUCT_BRAND,getProductBrand()));

	c.add(getCondition(Product.MODEL,getModel()));

	c.add(getCondition(Product.SPEC,getSpec()));

	c.add(getCondition(Product.UNIT_PRICE,getUnitPrice()));

	c.add(getCondition(Product.PRODUCT_UNIT,getProductUnit()));

	c.add(getCondition(Product.QUALITY_ASSURE_PERIOD,getQualityAssurePeriod()));

	c.add(getCondition(Product.MANUFATURER,getManufaturer()));

	c.add(getCondition(Product.AREA,getArea()));
	

	//c.add(getCondition(Product.PROVIDER_CODE,getProviderCode()));
	String providerSql = " in (select code from t_provider where 1=1 ";
	boolean providerFlag = false;
	int keycount = 0;
	if (!getProviderCode().equals(""))
	{
	    providerSql += "and name like ? ";
	    providerFlag = true;
	    keycount++;
	    //c.add(Product.PROVIDER_CODE + " in (select code from t_provider where name= ? )",Conditions.CUSTOM,getProviderCode());
	    //c.add(Product.PROVIDER_CODE,Conditions.IN,getProviderCodes());
	}
	if(!getProviderStatus().equals("")){
	    providerSql += "and status = ? ";
        providerFlag = true;
        keycount++;
	}
	String[] pkey = new String[keycount];
	for(int i = 0; i < pkey.length; i++){
	    pkey[i] = "";
	}
	if(providerFlag){
	    providerSql += ")";
	    if(!getProviderCode().equals("")){
	        for(int i = 0; i < pkey.length; i++){
	            if(pkey[i].equals("")){
	                pkey[i] = "%"+getProviderCode()+"%";
	                break;
	            }
	        }
	    }
	    if(!getProviderStatus().equals("")){
            for(int i = 0; i < pkey.length; i++){
                if(pkey[i].equals("")){
                    pkey[i] = getProviderStatus();
                    break;
                }
            }
        }
	    
	    c.add(Product.PROVIDER_CODE + providerSql, Conditions.CUSTOM, pkey);
	}
	

	c.add(getCondition(Product.ADAPT_MACHINE_TYPE,getAdaptMachineType()));

	c.add(getCondition(Product.PIC,getPic()));

	c.add(getCondition(Product.RECENT_ADJUSTPRICE_DATE,getRecentAdjustpriceDate()));

	c.add(getCondition(Product.RECENT_ADJUSTED_PRICE,getRecentAdjustedPrice()));

	c.add(getCondition(Product.RECORDER_ID,getRecorderId()));

	c.add(getCondition(Product.RECORD_DATE,getRecordDate()));

	c.add(getCondition(Product.IS_TRADEFLAT_PRODUCT,getIsTradeflatProduct()));

	c.add(getCondition(Product.APPENDER_PROPERTY,getAppenderProperty()));

	c.add(getCondition(Product.REMARK,getRemark()));

	c.add(getCondition(Product.DRAWING_PIECE_CODE,getDrawingPieceCode()));

	c.add(getCondition(Product.BALANCE_MODE,getBalanceMode()));

	c.add(getCondition(Product.IS_NORMAL,getIsNormal()));
	if(getIsWarehouseCategoryProduct()==null||getIsWarehouseCategoryProduct().trim().equals("")){
	    if(getWarehouseCode() == null || "".equals(getWarehouseCode())){
	        c.add("WAREHOUSE_CODE = ?", Conditions.CUSTOM, "00");
	    } 
	    else{
	        StringTokenizer st = new StringTokenizer(getWarehouseCode(), "|");
	        String code = "";
	        int count = 0;
	        while(st.hasMoreElements()){
	            code = st.nextToken();
	            count++;
	        }
	        if("00".equals(code)){
	            c.add("WAREHOUSE_CODE like ?", Conditions.CUSTOM, "00%");
	        }
	        else{
	            if(count > 1){
	                String[] key = new String[2];
	                key[0] = "00";
	                key[1] = code + "%";
	                c.add("(WAREHOUSE_CODE = ? OR WAREHOUSE_CODE like ?)", Conditions.CUSTOM, key);
	            }
	            else{
	                c.add("WAREHOUSE_CODE like ?", Conditions.CUSTOM, code + "%");
	            }    
	        }
	    } 
    }
	
	
	isAuditing(c);

	//if("00".equals(getWarehouseCode())){
	//    c.add("WAREHOUSE_CODE = ?", Conditions.CUSTOM, getWarehouseCode());
	//}
    //if(!"00".equals(getWarehouseCode())){
    //    String key[] = new String[]{"00", getWarehouseCode() + "%"};
	//    c.add("(WAREHOUSE_CODE = ? OR WAREHOUSE_CODE like ?)", Conditions.CUSTOM, key);
	//}    

	c.add(getCondition(Product.WAREHOUSE_NAME,getWarehouseName()));

	c.add(getCondition(Product.IS_BUY,getIsBuy()));

	c.add(getCondition(Product.STATUS,getStatus()));
	
	c.add(getCondition(Product.AUDITING_STATUS,getAuditingStatus()));

	c.add(getCondition(Product.CREATE_USER_ID,getCreateUserId()));

	c.add(getCondition(Product.CREATE_USER,getCreateUser()));

	c.add(getCondition(Product.CREATE_TIME,getCreateTime()));

	c.add(getCondition(Product.LAST_UPDATE_USER_ID,getLastUpdateUserId()));

	c.add(getCondition(Product.LAST_UPDATE_USER,getLastUpdateUser()));

	c.add(getCondition(Product.LAST_UPDATE_TIME,getLastUpdateTime()));
	//c.add("NAME like '%"+getI_mhcx()+"%' or CONCENTRICITY_CODE like '%"+getI_mhcx()+"%'" +
           // "or MODEL like '%"+getI_mhcx()+"%' or SPEC like '%"+getI_mhcx()+"%' or PRODUCT_BRAND like '%"+getI_mhcx()+"%' or MANUFATURER like '%"+getI_mhcx()+"%'",Conditions.CUSTOM,getI_mhcx());
		
	//关键字 
    // modify by wangp 2007-07-30
    if (!getKeyWord().equalsIgnoreCase(""))
    {
        //c.add(" 1=1 ");
        String[] keyWord = new String[7];
        keyWord[0] = "%" + viewKeyWord().toUpperCase() + "%";
        keyWord[1] = viewKeyWord().toUpperCase();
        keyWord[2] = "%" + viewKeyWord().toUpperCase() + "%";
        keyWord[3] = "%" + viewKeyWord().toUpperCase() + "%";
        keyWord[4] = "%" + viewKeyWord().toUpperCase() + "%";
        keyWord[5] = "%" + viewKeyWord().toUpperCase() + "%";
        keyWord[6] = "%"+viewKeyWord().toUpperCase()+"%";
        //keyWord[7] = "%" + viewKeyWord().toUpperCase() + "%";
        
        c.add("( NAME like ? or CONCENTRICITY_CODE = ? or MODEL like ? " +
              "or SPEC like ? or PRODUCT_BRAND like ? or MANUFATURER like ?"+"or APPENDER_PROPERTY like ? )",Conditions.CUSTOM,keyWord); 
//            "or exists (select t_customer_code.item_id from t_customer_code where t_item.id = t_customer_code.item_id and t_customer_code.PUR_ID = "+ getSearchProductPurId() + " and upper(t_customer_code.customer_code) like ? ))");
    }
    //出入库产品里没有设置产品属性
    doInAndOutNotProductCategory(c);
    if(getIsWarehouseCategoryProduct()==null||!getIsWarehouseCategoryProduct().trim().equals("1")){
     if(!getCreateTimeStart().equalsIgnoreCase(""))
    {
        c.add(" CREATE_TIME >= ?", Conditions.CUSTOM, getCreateTimeStart() + " 00:00:00");
    }
    
    if(!getCreateTimeEnd().equalsIgnoreCase(""))
    {
        c.add(" CREATE_TIME <= ?", Conditions.CUSTOM, getCreateTimeEnd() + " 23:59:59");
    }
    }
    

    // add by wing start
    /*
 
    if (getProductCodes() != null) {
        String sql = " CONCENTRICITY_CODE not in (";
        for (int i=0;i<m_product_codes.length;i++) {
            if(i==0)
            {
                sql += "?";
            }
            else
            {
                sql += ",?" ;
            }
        }
        sql += ")";
        c.add(sql,Conditions.CUSTOM,getProductCodes());
    }
    */
    
    // add by wing end

		return c ;
	}



    /**出入库产品没有设置产品属性
     * @param c
     * @throws Exception
     */
    private void doInAndOutNotProductCategory(Conditions c) throws Exception {

        if(getIsWarehouseCategoryProduct()!=null&&getIsWarehouseCategoryProduct().trim().equals("1")){
            if(getCreateTimeStart()!=null&&getCreateTimeStart().trim().length()>0)
            {   
                if(getCreateTimeEnd()!=null&&getCreateTimeEnd().trim().length()>0){
                    String notCategorySql = " in (select product_id from t_warehouse_product where warehouse_code like '"+getSearhWarehouseCode()+"%' ) and concentricity_code  in "+
                    "(select distinct product_code  from "+
                        "(select distinct product_code from t_in_sub where  in_bill_code in (select in_bill_code from t_in_head where  warehouse_code like '"+getSearhWarehouseCode()+"%' and in_time>=? and in_time<=?)"+ 
                         " union all "+ 
                          "select distinct product_code from t_out_sub where  out_bill_code in (select out_bill_code from t_out_head where  out_time>=? and out_time<=? and warehouse_code like '"+getSearhWarehouseCode()+"%')) a where a.product_code not in "+
                         "(select product_code from t_warehouse_category_relation where warehouse_code like '"+getSearhWarehouseCode()+"%')) "; 

                    c.add(Product.ID+notCategorySql,Conditions.CUSTOM,new String[]{getCreateTimeStart(),getCreateTimeEnd(),getCreateTimeStart(),getCreateTimeEnd()} );
                }else{
                    String notCategorySql = " in (select product_id from t_warehouse_product where warehouse_code like '"+getSearhWarehouseCode()+"%' ) and concentricity_code  in "+
                    "(select distinct product_code  from "+
                        "(select distinct product_code from t_in_sub where  in_bill_code in (select in_bill_code from t_in_head where  warehouse_code like '"+getSearhWarehouseCode()+"%' and in_time>=? )"+ 
                         " union all "+ 
                          "select distinct product_code from t_out_sub where  out_bill_code in (select out_bill_code from t_out_head where  out_time>=?  and warehouse_code like '"+getSearhWarehouseCode()+"%')) a where a.product_code not in "+
                         "(select product_code from t_warehouse_category_relation where warehouse_code like '"+getSearhWarehouseCode()+"%')) "; 

                    c.add(Product.ID+notCategorySql,Conditions.CUSTOM,new String[]{getCreateTimeStart(),getCreateTimeStart()});
              
                }
             }else if(getCreateTimeEnd()!=null&&getCreateTimeEnd().trim().length()>0){
                 String notCategorySql = " in (select product_id from t_warehouse_product where warehouse_code like '"+getWarehouseCode()+"%' ) and concentricity_code  in "+
                 "(select distinct product_code  from "+
                     "(select distinct product_code from t_in_sub where  in_bill_code in (select in_bill_code from t_in_head where  warehouse_code like '"+getWarehouseCode()+"%' and in_time<=? )"+ 
                      " union all "+ 
                       "select distinct product_code from t_out_sub where  out_bill_code in (select out_bill_code from t_out_head where  out_time<=?  and warehouse_code like '"+getWarehouseCode()+"%')) a where a.product_code not in "+
                      "(select product_code from t_warehouse_category_relation where warehouse_code like '"+getWarehouseCode()+"%')) "; 

                 c.add(Product.ID+notCategorySql,Conditions.CUSTOM,new String[]{getCreateTimeEnd(),getCreateTimeEnd()} );

            }else{
                String notCategorySql = " in (select product_id from t_warehouse_product where warehouse_code like ?) and concentricity_code  in "+
                "(select distinct product_code  from "+
                    "(select distinct product_code from t_in_sub where  in_bill_code in (select in_bill_code from t_in_head where  warehouse_code like ? )"+ 
                     " union all "+ 
                      "select distinct product_code from t_out_sub where  out_bill_code in (select out_bill_code from t_out_head where  warehouse_code like ?)) a where a.product_code not in "+
                     "(select product_code from t_warehouse_category_relation where warehouse_code like ?)) "; 

                c.add(Product.ID+notCategorySql,Conditions.CUSTOM ,new String []{getWarehouseCode()+"%",getWarehouseCode()+"%",getWarehouseCode()+"%",getWarehouseCode()+"%"});

            } 
        }
    }



    /**
     * @param c
     * @throws Exception
     */
    private void isAuditing(Conditions c) throws Exception {
        if(this.is_auditing){
            String [] warehouseCodes = GSBaseConstants.WAREHOUSTS_NO_AUDITING;
            if(warehouseCodes.length>0){
                for(int k=0;k<warehouseCodes.length;k++){
                    if(!warehouseCodes[k].trim().equals("")){
                        c.add("WAREHOUSE_CODE <>  ?", Conditions.CUSTOM, warehouseCodes[k]);    
                    }
                }
            }  
        }
    }

	/**
     * @param aProviderSearchEvent the providerSearchEvent to set
     */
   /* public void setProviderSearchEvent(ProviderSearchEvent aProviderSearchEvent) {
        this.providerSearchEvent = aProviderSearchEvent;
    }
*/

    /**
     * @return the providerSearchEvent
     */
	/*
    public ProviderSearchEvent getProviderSearchEvent() {
        return this.providerSearchEvent;
    }
    */

   /* public ProviderSearchEvent viewProviderSearchEvent()throws Exception{
        return Value.view(getProviderSearchEvent());
        Value.view
    }
    */
	
    //add by chengbiao.he start

	private String[] m_provider_codes = null;
	
	public String[] getProviderCodes()
    {
        return m_provider_codes ;
    }
    public void setProviderCodes(String[] v)
    {
        m_provider_codes = v;
    }	

    private String[] m_category_codes = null;
    
    public String [] getCategoryCodes(){
        return m_category_codes;
    }
    public void setCategoryCodes(String [] v){
        m_category_codes = v;
    }
  
    //add by chengbiao.he end
    
    // add by Jackey start
    private String m_upper_category_code = "";    
    public String getUpperCategoryCode()
    {
        return m_upper_category_code ;
    }
    public void setUpperCategoryCode(String v)
    {
        m_upper_category_code = v;
    }           
    public String viewUpperCategoryCode() throws Exception
    {
        return Value.view(getUpperCategoryCode());
    }    
    
    private String m_grandfather_category_code = "";    
    public String getGrandfatherCategoryCode()
    {
        return m_grandfather_category_code ;
    }
    public void setGrandfatherCategoryCode(String v)
    {
        m_grandfather_category_code = v;
    }     
    public String viewGrandfatherCategoryCode() throws Exception
    {
        return Value.view(getGrandfatherCategoryCode());
    }   
    // add by Jackey end    
    
    // add by wing start
    private String[] m_product_codes = null;
    
    public String[] getProductCodes()
    {
        return m_product_codes ;
    }
    public void setProductCodes(String[] v)
    {
        m_product_codes = v;
    }
    // add by wing end



    /**
     * @return the is_auditing
     */
    public boolean isIs_auditing() {
        return this.is_auditing;
    }



    /**
     * @param aIs_auditing the is_auditing to set
     */
    public void setIs_auditing(boolean aIs_auditing) {
        this.is_auditing = aIs_auditing;
    }
    private String m_start_outTime = "";
    public String getStartOutTime() {
        return this.m_start_outTime;
    }
    public void setStartOutTime(String startOutTime) {
        this.m_start_outTime = startOutTime;
    }
    
    private String m_end_outTime = "";
    public String getEndOutTime() {
        return this.m_end_outTime;
    }
    public void setEndOutTime(String endOutTime) {
        this.m_end_outTime = endOutTime;
    }



    /**
     * @return the m_is_warehouse_category_product
     */
    public String getIsWarehouseCategoryProduct() {
        return this.m_is_warehouse_category_product;
    }



    /**
     * @param aM_is_warehouse_category_product the m_is_warehouse_category_product to set
     */
    public void setIsWarehouseCategoryProduct(String aM_is_warehouse_category_product) {
        this.m_is_warehouse_category_product = aM_is_warehouse_category_product;
    }
    
    public String m_upper_type = "";
    
    public String getUpperType() {
        return this.m_upper_type;
    }
    public void setUpperType(String upperType) {
        this.m_upper_type = upperType;
    }
    
    public String m_product_type = "";
    
    public String getProductType() {
        return this.m_product_type;
    }
    public void setProductType(String productType) {
        this.m_product_type = productType;
    }

    private String is_count_product_type = "";  

	public String getIsCountProductType() {
		return is_count_product_type;
	}
	public void setIsCountProductType(String is_count_product_type) {
		this.is_count_product_type = is_count_product_type;
	}

	public String getProductTypeProviderCode() {
		return m_product_type_provider_code;
	}

	public void setProductTypeProviderCode(String provider_code) {
		this.m_product_type_provider_code = provider_code;
	}
	
	
    
}
